#include "surf_window.h"

surf_window::surf_window(QWidget *parent)
    : CommonGraphicsView{parent}
{

}

void surf_window::dropEvent(QDropEvent *event){
    filePath = event->mimeData()->urls().at(0).toLocalFile();
    showSURF(filePath.toStdString().c_str());
}

void surf_window::showSURF(const char* filePath){
    Mat src = imread("D:/vcprojects/images/HOGV.png");
        if (src.empty()) {
            printf("could not load image...\n");
        }
        imshow("input image", src);

        /*Mat dst, dst_gray;
        resize(src, dst, Size(64, 128));
        cvtColor(dst, dst_gray, COLOR_BGR2GRAY);
        HOGDescriptor detector(Size(64, 128), Size(16, 16), Size(8, 8), Size(8, 8), 9);

        vector<float> descriptors;
        vector<Point> locations;
        detector.compute(dst_gray, descriptors, Size(0, 0), Size(0, 0), locations);
        printf("number of HOG descriptors : %d", descriptors.size());
        */
//        HOGDescriptor hog = HOGDescriptor();
//        hog.setSVMDetector(hog.getDefaultPeopleDetector());

//        vector<Rect> foundLocations;
//        hog.detectMultiScale(src, foundLocations, 0, Size(8, 8), Size(32, 32), 1.05, 2);
//        Mat result = src.clone();
//        for (size_t t = 0; t < foundLocations.size(); t++) {
//            rectangle(result, foundLocations[t], Scalar(0, 0, 255), 2, 8, 0);
//        }
//        imshow("HOG SVM Detector Demo", result);


//    Mat src = imread("D:/vcprojects/images/test.png", IMREAD_GRAYSCALE);
//        if (src.empty()) {
//            printf("could not load image...\n");
//            return ;
//        }
//        imshow("input image", src);

//        int numFeatures = 400;
//        Ptr<SIFT> detector = SIFT::create(numFeatures);
//        vector<KeyPoint> keypoints;
//        detector->detect(src, keypoints, Mat());
//        printf("Total KeyPoints : %d\n", keypoints.size());

//        Mat keypoint_img;
//        drawKeypoints(src, keypoints, keypoint_img, Scalar::all(-1), DrawMatchesFlags::DEFAULT);
//        imshow("SIFT KeyPoints", keypoint_img);


//    src = imread(filePath);
//    if(src.empty()){
//        qDebug()<<"图片资源为空";
//        return;
//    }
//    imshow("src",src);
//    int minHessian=100;
//    Ptr<SURF> detector = SURF::create(minHessian);
//    vector<KeyPoint> keyPoints;
//    detector->detect(src,keyPoints,Mat());
//    drawKeypoints(src,keyPoints,resultImage,Scalar::all(-1),DrawMatchesFlags::DEFAULT);
//    imshow("key points",resultImage);

}
